@file:Suppress("unused")

package com.example.demo.model

import xyz.erupt.annotation.*
import xyz.erupt.annotation.sub_erupt.*
import xyz.erupt.annotation.sub_field.*
import xyz.erupt.annotation.sub_field.sub_edit.*
import xyz.erupt.upms.model.base.*
import javax.persistence.*

@Erupt(
    name = "文章发布",
    power = Power(importable = true, export = true),
    orderBy = "top desc",
)
@Entity
@Table(name = "demo_article")
class Article : HyperModel() {

    @EruptField(
        views = [View(title = "封面图")],
        edit = Edit(
            title = "封面图",
            type = EditType.ATTACHMENT,
            attachmentType = AttachmentType(type = AttachmentType.Type.IMAGE, maxLimit = 3),
        )
    )
    var pic: String? = null

    @EruptField(
        views = [View(title = "标题")],
        edit = Edit(title = "标题", notNull = true, search = Search(vague = true))
    )
    var title: String = ""

    @EruptField(
        views = [View(title = "置顶")],
        edit = Edit(title = "置顶", notNull = true, search = Search())
    )
    var top: Boolean = false

    @EruptField(
        views = [View(title = "发布状态")],
        edit = Edit(
            title = "发布状态",
            notNull = true,
            boolType = BoolType(trueText = "发布", falseText = "草稿"),
            search = Search(),
        )
    )
    var publish: Boolean = false

    @Lob
    @EruptField(
        views = [View(title = "内容(UEditor)", type = ViewType.HTML, export = false)],
        edit = Edit(title = "内容(UEditor)", type = EditType.HTML_EDITOR, notNull = true)
    )
    var content: String = ""

    @Lob
    @EruptField(
        views = [View(title = "内容(CKEditor)", type = ViewType.HTML, export = false)],
        edit = Edit(
            title = "内容(CKEditor)",
            type = EditType.HTML_EDITOR,
            htmlEditorType = HtmlEditorType(HtmlEditorType.Type.CKEDITOR),
        )
    )
    var content2: String? = null

    @Lob
    @EruptField(
        views = [View(title = "备注")],
        edit = Edit(title = "备注", type = EditType.TEXTAREA)
    )
    var remark: String? = null

}
